import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import pluginVue from "eslint-plugin-vue";
import { defineConfig } from "eslint/config";

export default defineConfig([
  {
    languageOptions: {
      globals: {
        ...globals.node,
        // 自定义全局变量如abc
        // abc: "readonly",
      },
    },
  },
  {
    files: ["**/*.{js,mjs,cjs,ts,d.ts,mts,cts,vue}"],
    plugins: { js },
    extends: ["js/recommended"],
    rules: {
      'no-undef': 'off',
      '@typescript-eslint/no-explicit-any': 'warn', // any 类型报警
      'no-useless-escape': 'off',
    },
  },
  {
    files: ["**/*.{js,mjs,cjs,ts,d.ts,mts,cts,vue}"],
    languageOptions: { globals: globals.browser },
  },
  tseslint.configs.recommended,
  pluginVue.configs["flat/essential"],
  {
    files: ["**/*.vue"],
    languageOptions: { parserOptions: { parser: tseslint.parser } },
    rules: {
      'no-undef': 'off',
      'vue/multi-word-component-names': 'off',
      '@typescript-eslint/no-explicit-any': 'warn', // any 类型报警
      'no-useless-escape': 'off',
    },
  },
]);
